<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>账号注册</title>
    <#assign path="${springMacroRequestContext.getContextPath()}" >
    <link rel="stylesheet" href="${path}/static/bootstrap-3.4.1/css/bootstrap.css" type="text/css"/>
    <link rel="stylesheet" href="${path}/static/bootstrap-3.4.1/css/bootstrap-theme.css" type="text/css"/>
    <script src="${path}/static/bootstrap-3.4.1/js/jquery.min.js"></script>
    <script src="${path}/static/bootstrap-3.4.1/js/bootstrap.js"></script>
</head>
</head>
<body>
<div class="container">
    <p></p>

    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">账号注册</h3>
        </div>
        <div class="panel-body">
            <form id="prodForm">
                <div class="form-group">
                    <label for="companyName">公司</label>
                    <select class="form-control" id="companyName" name="companyName">
                        <option value="基本粒子">基本粒子</option>
                        <option value="云栖工程院">云栖工程院</option>
                        <option value="其他">其他</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="account">*登录账号</label>
                    <input type="text" class="form-control" id="account" name="account" placeholder="请输入登录账号">
                </div>
                <div class="form-group">
                    <label for="pwd">*登录密码</label>
                    <input type="password" class="form-control" id="pwd" name="pwd" placeholder="请输入登录密码">
                </div>
                <div class="form-group">
                    <label for="realName">*真实姓名</label>
                    <input type="text" class="form-control" id="realName" name="realName" placeholder="请输入真实姓名">
                </div>
                <div class="form-group">
                    <label for="sex">性别</label>
                    <select class="form-control" id="sex" name="sex">
                        <option value="帅哥">帅哥</option>
                        <option value="美女">美女</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="mobile">*手机号</label>
                    <input type="text" class="form-control" id="mobile" name="mobile" placeholder="请输入手机名">
                </div>
                <div class="form-group">
                    <label for="email">电子邮箱</label>
                    <input type="text" class="form-control" id="email" name="email" placeholder="请输入电子邮箱">
                </div>
                <div class="form-group">
                <div class="alert bg-danger" id="warnTips" style="display: none;"></div>
                <div class="alert bg-info" id="doingTips" style="display: none;">提交中</div>
                <div class="alert bg-primary" id="successTips" style="display: none;">账号注册提交成功，请联系管理员</div>
                <button type="button" class="btn btn-primary" id="sub1">提交</button>
                </div>
                <div class="form-group">
                <a href="/login">去登录</a>
                </div>
        </form>
    </div>
</div>
</div>

<script type="text/javascript">
    $("#sub1").click(function () {
        if ("" == $("#account").val()) {
            $(".alert").hide();
            $("#warnTips").html("请输入登录账号").show();
            return;
        } else if ("" == $("#pwd").val()) {
            $(".alert").hide();
            $("#warnTips").html("请输入登录密码").show();
            return;
        } else if ("" == $("#realName").val()) {
            $(".alert").hide();
            $("#warnTips").html("请输入真实姓名").show();
            return;
        }else if ("" == $("#mobile").val()) {
            $(".alert").hide();
            $("#warnTips").html("请输入手机号").show();
            return;
        }
        $.ajax({
            url: '${path}/regist/submit',
            type: 'post',
            timeout: 30000,
            data: $("#prodForm").serialize(),
            beforeSend: function () {
                $(".alert").hide();
                $("#doingTips").show();
            },
            success: function (result) {
                if (0 == result.error) {
                    $("#prodForm").find("input").each(function () {
                        if ($(this).attr("name") != undefined && $(this).attr("name") !== "") {
                            $(this).val("");
                        }
                    })
                    $(".alert").hide();
                    $("#successTips").show();
                    setTimeout(function (){
                        window.location.href="${path}/login";
                    },10000);
                } else {
                    $(".alert").hide();
                    $("#warnTips").html(result.msg).show();
                }

            }
        });
    });
</script>
</body>
</html>